<template>
  <div class="page_search search_index">
	<div class="warp">
	  <div class="container">
		<div class="row">
		  <div class="col-12">
			<div class="card_result_search">
			  <div class="title">搜索结果</div>
				<!-- 商品搜索结果 -->
			  <list_result_search
				:list="result_goods"
				title="服装商城"
				source_table="goods"
			  ></list_result_search>



						  <list_result_search
				v-if="$check_action('/regular_users/list', 'get')"
				:list="result_regular_users_user_name"
				title="普通用户用户姓名"
				source_table="regular_users"
			  ></list_result_search>
															  <list_result_search
				v-if="$check_action('/clothing_mall/list', 'get')"
				:list="result_clothing_mall_clothing_specifications"
				title="服装商城服装规格"
				source_table="clothing_mall"
			  ></list_result_search>
												  <list_result_search
				v-if="$check_action('/clothing_specifications/list', 'get')"
				:list="result_clothing_specifications_clothing_specifications"
				title="服装规格服装规格"
				source_table="clothing_specifications"
			  ></list_result_search>
									  <list_result_search
				v-if="$check_action('/exchange_forum/list', 'get')"
				:list="result_exchange_forum_post_title"
				title="交流论坛帖子标题"
				source_table="exchange_forum"
			  ></list_result_search>
																		  <list_result_search
				v-if="$check_action('/activity_tasks/list', 'get')"
				:list="result_activity_tasks_task_title"
				title="活动任务任务标题"
				source_table="activity_tasks"
			  ></list_result_search>
															</div>
		  </div>
		</div>
	  </div>
	</div>
  </div>
</template>

<script>
import mixin from "../../mixins/page.js";
import list_result_search from "../../components/diy/list_result_search.vue";

export default {
  mixins: [mixin],
  data() {
	return {
	  "query": {
		word: "",
	  },
	  "result_goods": [],
						"result_regular_users_user_name":[],
															"result_clothing_mall_clothing_specifications":[],
												"result_clothing_specifications_clothing_specifications":[],
									"result_exchange_forum_post_title":[],
																		"result_activity_tasks_task_title":[],
													};
  },
  methods: {
	/**
	 * 获取${fmodel.filter.cart_name}
	 */
	get_goods() {
	  this.$get("~/api/goods/get_list?like=0", { page: 1, size: 10, title: this.query.word }, (json) => {
		if (json.result) {
		  this.result_goods = json.result.list;
		}
	  });
	},

				/**
	 * 获取user_name
	 */
	get_regular_users_user_name(){
		let url = "~/api/regular_users/get_list?like=0";
				this.$get(url, { page: 1, size: 10, "user_name": this.query.word }, (json) => {
		  if (json.result) {
			var result_regular_users_user_name = json.result.list;
			result_regular_users_user_name.map(o => o.title = o['user_name'])
	  			this.result_regular_users_user_name = result_regular_users_user_name
		 	}
		});
	},
													/**
	 * 获取clothing_specifications
	 */
	get_clothing_mall_clothing_specifications(){
		let url = "~/api/clothing_mall/get_list?like=0";
				this.$get(url, { page: 1, size: 10, "clothing_specifications": this.query.word }, (json) => {
		  if (json.result) {
			var result_clothing_mall_clothing_specifications = json.result.list;
			result_clothing_mall_clothing_specifications.map(o => o.title = o['clothing_specifications'])
	  			this.result_clothing_mall_clothing_specifications = result_clothing_mall_clothing_specifications
		 	}
		});
	},
										/**
	 * 获取clothing_specifications
	 */
	get_clothing_specifications_clothing_specifications(){
		let url = "~/api/clothing_specifications/get_list?like=0";
				this.$get(url, { page: 1, size: 10, "clothing_specifications": this.query.word }, (json) => {
		  if (json.result) {
			var result_clothing_specifications_clothing_specifications = json.result.list;
			result_clothing_specifications_clothing_specifications.map(o => o.title = o['clothing_specifications'])
	  			this.result_clothing_specifications_clothing_specifications = result_clothing_specifications_clothing_specifications
		 	}
		});
	},
							/**
	 * 获取post_title
	 */
	get_exchange_forum_post_title(){
		let url = "~/api/exchange_forum/get_list?like=0";
				this.$get(url, { page: 1, size: 10, "post_title": this.query.word }, (json) => {
		  if (json.result) {
			var result_exchange_forum_post_title = json.result.list;
			result_exchange_forum_post_title.map(o => o.title = o['post_title'])
	  			this.result_exchange_forum_post_title = result_exchange_forum_post_title
		 	}
		});
	},
																/**
	 * 获取task_title
	 */
	get_activity_tasks_task_title(){
		let url = "~/api/activity_tasks/get_list?like=0";
				this.$get(url, { page: 1, size: 10, "task_title": this.query.word }, (json) => {
		  if (json.result) {
			var result_activity_tasks_task_title = json.result.list;
			result_activity_tasks_task_title.map(o => o.title = o['task_title'])
	  			this.result_activity_tasks_task_title = result_activity_tasks_task_title
		 	}
		});
	},
												
  },
  components: { list_result_search },
	created(){
    this.query.word = this.$route.query.word || "";
  },
  mounted() {
	this.get_goods();
					this.get_regular_users_user_name();
														this.get_clothing_mall_clothing_specifications();
											this.get_clothing_specifications_clothing_specifications();
								this.get_exchange_forum_post_title();
																	this.get_activity_tasks_task_title();
												  },
  watch: {
	$route() {
	  $.push(this.query, this.$route.query);
	  this.get_goods();
				  this.get_regular_users_user_name();
													  this.get_clothing_mall_clothing_specifications();
										  this.get_clothing_specifications_clothing_specifications();
							  this.get_exchange_forum_post_title();
																  this.get_activity_tasks_task_title();
													},
  },
};
</script>

<style scoped>
.card_search {
  text-align: center;
}
.card_result_search>.title {
  text-align: center;
  padding: 10px 0;
}
</style>
